package psi.vote.view.bean;

import psi.vote.view.interfaces.IVoteSystem;
import psi.vote.view.service.VoteSystemRest;

import javax.faces.bean.ManagedBean;
import javax.faces.bean.RequestScoped;
import java.io.Serializable;

/**
 * Created with IDEA.
 * Voter: Ѱ
 * Date: 12.10.14
 * Time: 12:23
 */
@ManagedBean
@RequestScoped
public class UserBean implements Serializable {
    IVoteSystem system;
    private String email;


    public UserBean() {
        system = new VoteSystemRest();
    }


    public String getEmail() {
        return email;
    }

    public void setEmail(String email) {
        this.email = email;
    }

    public String doCheck() {

        if (system.isAlreadyVote(email)) {
            return "/cancel.xhtml";
        } else {
            return "/vote.xhtml";
        }

    }

}
